/*=========================================================================

Program:   Virtual Surgery
Language:  C++
Date:      2009-9-1
Version:   0.1
Mail:		   nelfylee@gmail.com

Copyright (c) 2009 Nelfy Lee. All rights reserved.

=========================================================================*/
#ifndef _CONTROL_PANEL_HOME_H_
#define _CONTROL_PANEL_HOME_H_

#include "ControlPanelBase.h"
#include "ui_ControlPanelHome.h"

#include <QDebug>
#include <QLabel>

#include "Source.h"
#include "vtkImageData.h"

class ControlPanelHome : public ControlPanelBase
{
	Q_OBJECT

public:
	ControlPanelHome(QWidget *parent) : ControlPanelBase(parent)
	{
		m_ui.setupUi(this);

		m_panelType = ptHome;

		connect(m_ui.btn_smoothing, SIGNAL(clicked()), SLOT(slotShowSmoothingPanel()));
		connect(m_ui.btn_vessel, SIGNAL(clicked()), SLOT(slotShowVesselSegmentationPanel()));
		connect(m_ui.btn_liver, SIGNAL(clicked()), SLOT(slotShowLiverSegmentationPanel()));
		connect(m_ui.btn_surface, SIGNAL(clicked()), SLOT(slotShowSurfacePanel()));
		connect(m_ui.btn_volume, SIGNAL(clicked()), SLOT(slotShowVolumePanel()));
		connect(m_ui.btn_threshold, SIGNAL(clicked()), SLOT(slotShowThresholdingPanel()));
		connect(m_ui.btn_liverdivision, SIGNAL(clicked()), SLOT(slotDoCenterLineExtraction()));
	}

	~ControlPanelHome(){}

	virtual void setSource(const QModelIndex& index)
	{
		ControlPanelBase::setSource(index);

		Source *source = currentSource();

		if ( !source)
			return;

		vtkImageData* data = source->data();

		if (data)
		{
			int dims[3];

			data->GetDimensions(dims);
			QString str = QString("%1, %2, %3").arg(dims[0]).arg(dims[1]).arg(dims[2]);

			m_ui.label_dimension->setText(str);
			m_ui.label_scalarType->setText(data->GetScalarTypeAsString());
		}
		

		//slotDoCenterLineExtraction();
	}

private slots:
	void slotShowSmoothingPanel() {	emit emitShowPanel(ptSmoothing);}
	void slotShowVesselSegmentationPanel() {	emit emitShowPanel(ptVesselSegmentation);}
	void slotShowLiverSegmentationPanel() {	emit emitShowPanel(ptLiverSegmentation);}
	void slotShowSurfacePanel() { emit emitShowPanel(ptSurface); }
	void slotShowVolumePanel() {	emit emitShowPanel(ptVolume);}
	void slotShowThresholdingPanel() {	emit emitShowPanel(ptThresholding);}
	void slotDoCenterLineExtraction() { emit emitShowPanel(ptCenterLine);}

signals:
	void emitShowPanel(PanelType pt);

private:
	Ui::ControlPanelHome m_ui;
};

#endif
